﻿<template>
    <div class="hidden h100 flex-column">
        <component is="style" />
        <el-tabs type="border-card" v-model="query.tab">
            <el-tab-pane :label="item.text" :name="item.value" v-for="item in urlList"></el-tab-pane>
        </el-tabs>
        <div class="padding-top-6 text-right">
            <el-pagination background v-on:size-change="pagerSizeChange" v-on:current-change="pagerIndexChange" :current-page="query.pageIndex" :page-size="query.pageSize" layout="prev, pager, next, total, jumper, sizes" :total="query.rowCount" :small="true"></el-pagination>
        </div>
        <div class="flex-column-fill">
            <el-row :gutter="20">
                <el-col :span="6" v-for="(item, index) in items" :key="index">
                    <div class="grid-content bg-purple">
                        <img :src="item.src" alt="">
                    </div>
                </el-col>
            </el-row>
        </div>
    </div>
</template>
<script>
    module = (function (hxt) {
        return {
            name: '303',
            props: {

            },
            data: function () {
                var _this = this, optor = hxt.store.optor;
                return {
                    optor: optor,
                    query: { tab: 0 },
                    previewImg:0,
                    urlList: [{
                        text: '黑丝',
                        value: 0,
                        icon: 'home-o',
                        p: ' 素颜API',
                        url: 'https://api.suyanw.cn/api/hs.php',
                        show: true,
                        type: 'arraybuffer',
                        groupKey: '6FDE326A-C114-4486-A8C5-C0167A9EEFC0'
                    }, {
                        text: '美女写真',
                        p: '免费API',
                        icon: 'search',
                        value: 1,
                        url: 'https://www.8iu.cc/Api/2',
                        show: false,
                        type: 'arraybuffer',
                        for: 1,
                        groupKey: '6A7F9D6B-3797-49DF-B48C-50C5EEC6BEE7'
                    }, {
                        text: '集美',
                        p: '免费API',
                        icon: 'search',
                        value: 2,
                        url: 'https://www.8iu.cc/Api/7',
                        show: false,
                        type: 'arraybuffer',
                        for: 1,
                        groupKey: 'EBCBD03D-3FA5-44D1-8318-2B37052CA36F'
                    }, {
                        text: '美腿',
                        p: ' 素颜API',
                        icon: 'friends-o',
                        value: 3,
                        url: 'https://api.suyanw.cn/api/meitui.php',
                        type: 'json',
                        show: true,
                        groupKey: '9C15E880-B345-4005-9E50-D54E4BAF5BEE'
                    }, {
                        text: '买家秀',
                        p: ' 素颜API',
                        icon: 'setting-o',
                        value: 4,
                        url: 'https://api.suyanw.cn/api/tbmjx.php?return=json',
                        type: 'json',
                        show: true,
                        groupKey: '322C8CD2-9FD0-47D2-A9C9-73A18D6F5C90'
                    }, {
                        text: '九黎',
                        p: ' 九黎API',
                        icon: 'setting-o',
                        value: 5,
                        url: 'http://jiuli.xiaoapi.cn/i/img/ikmjx.php',
                        type: 'json',
                        show: true,
                        for: 1,
                        groupKey: '5F4349DE-0EC3-4872-9509-A1A1C15FA47D'
                    }, {
                        text: 'JK',
                        p: '素颜API',
                        icon: 'setting-o',
                        value: 6,
                        url: 'https://api.suyanw.cn/api/jk.php',
                        type: 'arraybuffer',
                        show: true,
                        for: 4,
                        groupKey: '05B97566-0E83-4F01-956D-CA7BEB718B29'
                        }],
                    items: [
                        // 这里填充你的瀑布流图片数据
                        { src: 'image1.jpg' },
                        { src: 'image2.jpg' },
                    ],
                    list: [],
                    imglist: [],
                    imglistpreview: [],
                    query: {
                        pageIndex: 1,
                        pageSize: 30,
                        rowCount: 0

                    }
                }
            },
            computed: {

            },
            watch: {
                'query.tab': function (val) {
                    var _this = this;
                    _this.loadList();
                    _this.loadImg();
                },
            },
            activated: function () {
            },
            mounted: function () {
                var _this = this;
                _this.loadList();
            },
            methods: {
               
                loadList: function () {
                    var _this = this,
                        obj = _this.urlList[_this.query.tab];
                    if (!_this.isAdd) return;
                    _this.list = [];
                    _this.list = [obj.url];
                    if (_this.query.tab == 0) {
                        _this.list = [obj.url];
                        hxt.post({
                            url: hxt.config.link + 'pc/GetUrlToBase64',
                            data: { url: obj.url },
                            ok: function (res2) {
                                console.log(res2)
                                if (res2.code != 0) return hxt.error('失败：' + res2.errmsg);
                                //return
                                hxt.uploadFile({
                                    signUrl: hxt.config.link + 'pc/v3OssToken',
                                    base64: 'data:image/jpeg;base64,' + res2.data,
                                    file: null,
                                    compress: false,
                                    folder: 'img',
                                    success: function (res) {
                                        var mediaList = [{ miType: 2, miUrl: res.url, miBase64: res.raw64, miImgUrl: obj.url, miTitle: '【' + obj.text + '】-' + obj.p, miDesc: obj.url }];
                                        hxt.post({
                                            url: hxt.config.link + 'pc/mediaInfoSave',
                                            data: { miGroupKey: obj.groupKey, mediaList: encodeURI(JSON.stringify(mediaList)) },
                                            ok: function (res) {
                                                if (res.code != 0) return hxt.error('提交失败：' + res.errmsg);

                                            }
                                        });
                                    },
                                    fail: function (err) {
                                        hxt.unmask();
                                        hxt.error('附件上传失败：' + err);
                                    }
                                });
                            }
                        });
                    };
                    if (_this.query.tab == 6) {
                        _this.list = [obj.url];
                        hxt.post({
                            url: hxt.config.link + 'pc/GetUrlToBase64',
                            data: { url: obj.url },
                            ok: function (res2) {
                                console.log(res2)
                                if (res2.code != 0) return hxt.error('失败：' + res2.errmsg);
                                //return
                                hxt.uploadFile({
                                    signUrl: hxt.config.link + 'pc/v3OssToken',
                                    base64: 'data:image/jpeg;base64,' + res2.data,
                                    file: null,
                                    compress: false,
                                    folder: 'img',
                                    success: function (res) {
                                        var mediaList = [{ miType: 2, miUrl: res.url, miBase64: res.raw64, miImgUrl: obj.url, miTitle: '【' + obj.text + '】-' + obj.p, miDesc: obj.url }];
                                        hxt.post({
                                            url: hxt.config.link + 'pc/mediaInfoSave',
                                            data: { miGroupKey: obj.groupKey, mediaList: encodeURI(JSON.stringify(mediaList)) },
                                            ok: function (res) {
                                                if (res.code != 0) return hxt.error('提交失败：' + res.errmsg);

                                            }
                                        });
                                    },
                                    fail: function (err) {
                                        hxt.unmask();
                                        hxt.error('附件上传失败：' + err);
                                    }
                                });
                            }
                        });
                    };
                    if (_this.query.tab == 4) {
                        $.ajax({
                            url: obj.url,
                            type: "GET",
                            success: function (res1) {
                                console.log(res1.imgurl)
                                _this.list = [res1.imgurl];
                                hxt.post({
                                    url: hxt.config.link + 'pc/GetUrlToBase64',
                                    data: { url: res1.imgurl },
                                    ok: function (res2) {
                                        console.log(res2)
                                        if (res2.code != 0) return hxt.error('失败：' + res2.errmsg);
                                        //return
                                        hxt.uploadFile({
                                            signUrl: hxt.config.link + 'pc/v3OssToken',
                                            base64: 'data:image/jpeg;base64,' + res2.data,
                                            file: null,
                                            compress: false,
                                            folder: 'img',
                                            success: function (res) {
                                                var mediaList = [{ miType: 2, miUrl: res.url, miBase64: res.raw64, miImgUrl: res1.imgurl, miTitle: '【' + obj.text + '】-' + obj.p, miDesc: obj.url }];
                                                hxt.post({
                                                    url: hxt.config.link + 'pc/mediaInfoSave',
                                                    data: { miGroupKey: obj.groupKey, mediaList: encodeURI(JSON.stringify(mediaList)) },
                                                    ok: function (res) {
                                                        if (res.code != 0) return hxt.error('提交失败：' + res.errmsg);

                                                    }
                                                });
                                            },
                                            fail: function (err) {
                                                hxt.unmask();
                                                hxt.error('附件上传失败：' + err);
                                            }
                                        });
                                    }
                                });

                            }
                        });
                    };
                    if (_this.query.tab == 3) {
                        $.ajax({
                            url: obj.url,
                            type: "GET",
                            success: function (res1) {
                                console.log(res1)
                                _this.list = [res1];
                                hxt.post({
                                    url: hxt.config.link + 'pc/GetUrlToBase64',
                                    data: { url: res1 },
                                    ok: function (res2) {
                                        if (res2.code != 0) return hxt.error('提交失败：' + res2.errmsg);
                                        //return
                                        hxt.uploadFile({
                                            signUrl: hxt.config.link + 'pc/v3OssToken',
                                            base64: 'data:image/jpeg;base64,' + res2.data,
                                            file: null,
                                            compress: false,
                                            folder: 'img',
                                            success: function (res) {
                                                var mediaList = [{ miType: 2, miUrl: res.url, miBase64: res.raw64, miImgUrl: res1, miTitle: '【' + obj.text + '】-' + obj.p, miDesc: obj.url }];
                                                hxt.post({
                                                    url: hxt.config.link + 'pc/mediaInfoSave',
                                                    data: { miGroupKey: obj.groupKey, mediaList: encodeURI(JSON.stringify(mediaList)) },
                                                    ok: function (res) {
                                                        if (res.code != 0) return hxt.error('提交失败：' + res.errmsg);

                                                    }
                                                });
                                            },
                                            fail: function (err) {
                                                hxt.unmask();
                                                hxt.error('附件上传失败：' + err);
                                            }
                                        });
                                    }
                                });

                            }
                        });
                    };
                },
                pagerSizeChange: function (val) {
                    var _this = this;
                    _this.query.pageSize = val;
                    if (Math.ceil(_this.query.rowCount * 1.0000 / val) >= _this.query.pageIndex) _this.loadImg();
                },
                pagerIndexChange: function (val) {
                    var _this = this;
                    _this.query.pageIndex = val;
                    _this.loadImg();
                },
                loadImg: function () {
                    var _this = this,
                    obj = _this.urlList[_this.query.tab];
                    hxt.post({
                        url: hxt.config.link + 'pc/mediaInfoList',
                        data: { miGroupKey: obj.groupKey, pageSize: _this.query.pageSize, pageIndex: _this.query.pageIndex},
                        ok: function (res) {
                            if (res.code != 0) return hxt.error('加载失败：' + res.errmsg);
                            _this.imglist = res.data.list;
                            _this.query.pageSize = res.data.pageSize;
                            _this.query.pageIndex = res.data.pageIndex;
                            _this.query.rowCount = res.data.rowCount;
                            _this.imglistpreview = _this.imglist.map(function (item) { return item.miUrl });
                        }
                    });
                },
            },
            components: {
            }
        };
    })(window.$jscript.fn);
</script>
<style>
    .el-tab-pane {
        height: 100%;
    }

    .el-tabs__content {
        flex: 1;
    }

    .el-tabs--border-card > .el-tabs__content {
        padding: 0px !important;
    }
    .el-row {
        margin-bottom: 20px;
    }

    .el-col {
        border-radius: 4px;
        min-height: 1px;
    }

    .bg-purple-dark {
        background: #99a9bf;
    }

    .bg-purple {
        background: #d3dce6;
    }

    .bg-purple-light {
        background: #e5e9f2;
    }

    .grid-content {
        border-radius: 4px;
        min-height: 36px;
    }

        .grid-content img {
            width: 100%;
            height: auto;
        }
</style>